*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*	This is the NYC high school Master program for VAM2 analysis
*	----------------------------------------------------------------------------

	clear all
	set more off
	set maxvar 	120000
	set matsize 11000
	set emptycells drop
	graph set window fontface "CMU Serif"
	set scheme modern

*	city

	global city			NYC

*	paths

	global rawdata 				"${data_raw_NYC}"
	global cleandata 			"${data_clean_NYC}"
	global builddata 			"${data_build_NYC}"

*	sample

	if "$city" == "NYC"{
		local fg	 		9		// first grade
		local lg	 		9		// last grade
		local fy  			2012	// first year
		local ly	   		2014	// last year

		global stag
		global sectors screened

		local min_enroll	1
		local min_at_risk	1
	}

	local sample "_`fg'_`lg'_`fy'_`ly'"
	local sch_res "_e`min_enroll'_q`min_at_risk'"

*	controls

	global bl_demos bl_female bl_black bl_white bl_hispanic bl_asian bl_fr_lunch bl_sped bl_ell
	global bl_scores bl_math bl_ela bl_math2 bl_ela2 bl_math3 bl_ela3

	global iv_controls "i.year##(i.grade c.($bl_demos) c.($bl_scores))"

*	settings

	local ptype					form2
	local bw					"_ccftcovs_bwall"

	*	switches

		local descriptives			1	// Table 1
		local testing				1	// Table 2, 3, A3, A4
		local ivvam 				1   // Table 4, A6
		local balance				1	// Table A1
		local attrition				1	// Table A2
		local testing_het			1	// Table A5
		local viv					1	// Figure 1, A1
		local rmse					1	// Figure 2 (run simulate.m first)

	*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	*	do

		if `descriptives'				do "${code_analysis}a_descriptives"			`sample' `sch_res' `ptype' `bw'

		if `testing' {
										local het 0
										do "${code_analysis}a_testing"				`sample' `sch_res' `ptype' `het' `bw'
		}

		if `ivvam'						do "${code_analysis}a_ivvam"				`sample' `sch_res' `ptype' `bw'

		if `balance'					do "${code_analysis}a_balance"				`sample' `sch_res' `ptype' `bw'

		if `attrition'					do "${code_analysis}a_attrition"			`fg' `lg' `fy' `ly' `sch_res' `ptype' `bw'

		if `testing_het' {
										local het 1
										do "${code_analysis}a_testing"				`sample' `sch_res' `ptype' `het' `bw'
		}

		if `viv'						do "${code_analysis}a_viv"					`sample' `sch_res' `ptype' `bw'

		if `rmse'						do "${code_analysis}a_rmse"					`ptype'
